// pages/index/index.js
Page({
  data: {
    activeKey: "1",
    tabList: [
      {
        key: "1",
        label: "预约需知",
      },
      {
        key: "2",
        label: "常见问题",
      },
    ],
    notice: [],
    questionList: [],
  },
  async onLoad() {
    try {
      wx.showLoading({
        title: "加载中",
      });
      const res = await getApp().request({
        path: "/s/gi/listAppNotice",
        method: "GET",
      });
      const result = await getApp().request({
        path: "/s/gi/listProblems",
        method: "GET",
      });
      this.setData({
        notice: res,
      });
      this.setData({
        questionList: result,
      });
    } finally {
      wx.hideLoading();
    }
  },
  handleTabChange({ detail }: any) {
    this.setData({
      activeKey: detail.value,
    });
  },

  toggleExpand(e) {
    const index = parseInt(e.currentTarget.dataset.index);
    let { expandedIndexes } = this.data;
    if (expandedIndexes.includes(index)) {
      expandedIndexes = expandedIndexes.filter((i) => i !== index);
    } else {
      expandedIndexes.push(index);
    }
    this.setData({ expandedIndexes });
  },
});
